home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Microsoft Visual Basic .NET
/
Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin
/
07 attributes
/
attributesdemo
/
classes.vb
< prev
next >
Wrap
Text File
|
2002-03-16
|
2KB
|
66 lines
Imports System.Runtime.InteropServices
' this structure shows that you can map multiple values at the
' same offset in memory
<StructLayout(LayoutKind.Explicit)> _
Structure ARGBColor
<FieldOffset(0)> Dim Red As Byte
<FieldOffset(1)> Dim Green As Byte
<FieldOffset(2)> Dim Blue As Byte
<FieldOffset(3)> Dim Alpha As Byte
<FieldOffset(0)> Dim Value As Integer
End Structure
' a structure for converting integer data types
<StructLayout(LayoutKind.Explicit)> _
Structure IntegerTypes
' A 64-bit integer
<FieldOffset(0)> Dim Long0 As Long
' Two 32-bit integers
<FieldOffset(0)> Dim Integer0 As Integer
<FieldOffset(4)> Dim Integer1 As Integer
' Four 16-bit integers
<FieldOffset(0)> Dim Short0 As Short
<FieldOffset(2)> Dim Short1 As Short
<FieldOffset(4)> Dim Short2 As Short
<FieldOffset(6)> Dim Short3 As Short
' Eight 8-bit integers
<FieldOffset(0)> Dim Byte0 As Byte
<FieldOffset(1)> Dim Byte1 As Byte
<FieldOffset(2)> Dim Byte2 As Byte
<FieldOffset(3)> Dim Byte3 As Byte
<FieldOffset(4)> Dim Byte4 As Byte
<FieldOffset(5)> Dim Byte5 As Byte
<FieldOffset(6)> Dim Byte6 As Byte
<FieldOffset(7)> Dim Byte7 As Byte
' Low byte of a word
Function LowByte(ByVal Value As Long) As Byte
Long0 = Value
Return Byte0
End Function
' High byte of a word
Function HighByte(ByVal Value As Long) As Byte
Long0 = Value
Return Byte1
End Function
' Low word of a doubleword
Function LowWord(ByVal Value As Long) As Short
Long0 = Value
Return Short0
End Function
' High word of a doubleword
Function HighWord(ByVal Value As Long) As Short
Long0 = Value
Return Short1
End Function
End Structure